// baddoor.txt - so called because I am an unoriginal, talentless hack.
// basically here to emulate the smile pools of a/e3 that could be targetted by
// fire spells. 
// A very simple, naive text. Creature attacks anything it hates nearby.
// Once it has won, it returns to its home.
// Memory Cells:
//   Cell 0 - How creature moves.
//     0 - If 0, wander randomly. 
//     1 - Stands still until a target appears.
//     2 - Completely immobile, even if target appears.
//   Cell 1,2 - Stuff done flag. If both 0, nothing. Otherwise when this 
//     is killed, set to 1. (Example: If cell 1 is 3 and cell 2 is 5, when
//     creature is killed, sets SDF(3,5) to 1.)
//   Cell 3 - Dialogue node to start with if talked to. if left at 0, this
//     character doesn't talk.

begincreaturescript;

variables;

short i,j,target;

body;

beginstate INIT_STATE;
	set_mobility(ME,0);
		
	//Make it chicken, and never attack.
	set_courage(ME,0);
	set_aggression(ME,0);
	
	break;

beginstate DEAD_STATE;
	//Should never die, thus not needed.
break;

beginstate START_STATE; 

	j = get_flag(250,1);
	if(dist_to_char(j) > 2) {
		set_attitude(ME,10);
	} else {
		set_attitude(ME,4);
	}	
	if(get_health(ME) != (get_max_health(ME))) {
		put_boom_on_char(ME,1,0);
		run_animation_sound(-152);
		message_dialog("Your bolt of fire causes the metal in the door to melt slightly. As it grows hotter, it expands into the stone around it, rendering the door impassable.","You can move on to the next door now.");
		if(my_loc_x() == 10) {
			set_flag(0,21,1);
			inc_flag(0,10,1);
		}
		if(my_loc_x() == 12) {
			set_flag(0,19,1);
			inc_flag(0,10,1);
		}
		if(my_loc_x() == 51) {
			set_flag(0,20,1);
			inc_flag(0,10,1);
		}
		erase_char(ME);
	}
	
	end();
break;

beginstate 3; // attacking
	//Will never attack (one word from perfection... :P)
	set_state(START_STATE);
break;

beginstate TALKING_STATE;
	print_str("Doors can't talk...");
break;